<?php

//sql 连接
function dbconnect($db_user,$db_passwd,$db_name,$server = "localhost"){
    $db = new mysqli($server,$db_user,$db_passwd,$db_name,3306);
    $sql = "set names utf8";
    $db->query($sql);
    return $db;
}

//连接本地数据库
function local_db(){
    return dbconnect("<USER>","<PASSWORD>","<TABLE_NAME>");
}

//连接远程数据库
function remote_db(){
    $remote_ip = "<SQL_SERVER_IP>";
    return dbconnect("<USER>","<PASSWORD>","<TABLE_NAME>",$remote_ip);
}